package com.hzdesk.media.koreabatchmatvector.logic.view;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hzdesk.media.koreabatchmatvector.R;
import com.hzdesk.media.koreabatchmatvector.logic.contract.VideoListContract;
import com.hzdesk.media.koreabatchmatvector.logic.persenter.VideoListPersenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import me.zhouzhuo.zzhorizontalprogressbar.ZzHorizontalProgressBar;

/**
 * Created by Administrator on 2018/7/9.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 * TODO: 2018/7/10                                                                               本地视频
 */

public class VideoListActivity extends BaseActivity implements VideoListContract.IVideoListView {

    @BindView(R.id.activity_vido_list_iv_back)
    ImageView activityVidoListIvBack;
    @BindView(R.id.activity_vido_list_iv_intent_to_cloud)
    ImageView activityVidoListIvIntentToCloud;
    @BindView(R.id.activity_vido_list_iv_delect_all)
    ImageView activityVidoListIvDelectAll;
    @BindView(R.id.activity_vido_list_iv_sort)
    ImageView activityVidoListIvSort;
    @BindView(R.id.activity_vido_list_progress)
    ZzHorizontalProgressBar activityVidoListProgress;
    @BindView(R.id.activity_vido_list_tv_storage)
    TextView activityVidoListTvStorage;
    @BindView(R.id.activity_vido_list_listview)
    RecyclerView activityVidoListListview;
    @BindView(R.id.activity_vido_list_ll_bg)
    LinearLayout activityVidoListLlBg;

    private VideoListPersenter mVideoListPersenter = new VideoListPersenter(this);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vido_list);
        ButterKnife.bind(this);

    }

    @OnClick({R.id.activity_vido_list_iv_back, R.id.activity_vido_list_iv_intent_to_cloud, R.id.activity_vido_list_iv_delect_all, R.id.activity_vido_list_iv_sort})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_vido_list_iv_back:
                mVideoListPersenter.oncleckedBack();
                break;
            case R.id.activity_vido_list_iv_intent_to_cloud:
                mVideoListPersenter.onClickedToCulde();
                break;
            case R.id.activity_vido_list_iv_delect_all:
                mVideoListPersenter.onClickedDelectAll();
                break;
            case R.id.activity_vido_list_iv_sort:
                mVideoListPersenter.onCliakedSort();
                break;
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        final SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
        int selector = mSharedPreferences.getInt("item_skin", 0); //todo 名称
        activityVidoListLlBg.setBackgroundResource(updateBg[selector]);
        mVideoListPersenter.initDate(this, activityVidoListListview, getIntent());
    }

    @Override
    public void toVideoPlayerPager(String path) {
        Intent intent = new Intent(this, VideoPlayerActivity.class);
        intent.putExtra("vidofile_path", path);
        startActivity(intent);
    }

    @Override
    public void setLoclProgress(int progress) {
        activityVidoListProgress.setProgress(progress);
    }

    @Override
    public void toFinshPager() {
        finish();
    }

    @Override
    public void toCuldePager() {
        startActivity(new Intent(this, CloudListActivity.class));
    }

    @Override
    public void setStorageMessage(String msg) {
        activityVidoListTvStorage.setText(msg);
    }
}
